package com.zongxingh.consumer.hystrix.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * Introduction:  <简介>
 * Package Name:  com.zongxingh.consumer.ribbon.service
 * Project Name:  registry
 * Author:  zongxingh
 * Email： zongxingh@163.com
 * Tel: 157*****778
 * Create Time:  2020/6/17 15:04
 */

@Component
public class ConsumerRibbonHystrixService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "helloError")
    public String consumerHello(){
        return restTemplate.getForObject("http://service-hi/hi/hello",String.class);
    }


    public String helloError(){
        return "ConsumerRibbonHystrixService invoke remote service error !";
    }
}
